using System;
using UnityEngine;
using WeChatWASM;

#if 微信小游戏
public class 微信游戏圈按钮 : 微信按钮
{
    private WXGameClubButton 游戏圈按钮;
    [SerializeField] private GameClubButtonType 游戏圈按钮Type;
    [SerializeField] private GameClubButtonIcon 按钮类型Icon;
    [SerializeField] private string strParam;

    public event Action 获取信息成功回调;
    
    protected override void Show按钮()
    {
        Debug.Log("创建游戏圈按钮");
        base.Show按钮();
#if UNITY_EDITOR
        
        return;
#endif
        if (游戏圈按钮 == null)
        {
            var size = 微信需要的坐标_像素比;
            WXCreateGameClubButtonParam param = new WXCreateGameClubButtonParam();
            param.type = 游戏圈按钮Type;
            switch (游戏圈按钮Type)
            {
                case GameClubButtonType.text:
                    param.text = strParam;
                    break;
                case GameClubButtonType.image:
                    param.icon = 按钮类型Icon;
                    break;
            }

            param.style = new GameClubButtonStyle()
            {
                left = size.Item1,
                top = size.Item2,
                width = size.Item3,
                height = size.Item4,
            };
            // param.
            游戏圈按钮 = WX.CreateGameClubButton(param);
            游戏圈按钮.OnTap(() =>
            {
                Debug.Log("触发游戏圈按钮");
                获取信息成功回调?.Invoke();
                Hide按钮();
            });
        }
        
        游戏圈按钮.Show();
    }

    protected override void Hide按钮()
    {
        base.Hide按钮();
        if(游戏圈按钮 != null)
        {
            游戏圈按钮.Hide();
        }
    }
    
    protected override void 坐标修改()
    {
        base.坐标修改();
        if (cur按钮状态)
        {
            Hide按钮();
            游戏圈按钮 = null;
            Show按钮();
        }
    }
}

#endif
